<?php

namespace app\dao;

use app\model\TeacherModel;

class TeacherDao extends BaseDao
{
    protected $model;

    protected function setModel()
    {

        return TeacherModel::class;
    }

    public function __construct()
    {
        $this->model = new TeacherModel();
    }

    //增加
    public function addTeacherDao($data)
    {
        return $this->save($data);

        // 直接返回结果
    }


    //list

    public function listTeachersDao()
    {

        return $this->model->select();
    }

    public function getTeacher($id)
    {

        $record = $this->find($id);
        if (!$record) {
            throw new \Exception("教师记录不存在");
        }
        return $record;
    }

    //删除
    public function deleteTeacherDao($id)
    {


        $record = $this->find($id);
        if (!$record) {
            throw new \Exception("教师记录不存在");
        }
        $this->delete($id);
        return true;


    }


    //修改
    public function updateTeacherDao($id, $data)
    {


        return $this->edit($id, $data);


    }

}